/*
 * @Author: dfh
 * @Date: 2024-10-15 10:13:14
 * @LastEditors: dfh
 * @Modified By: dfh
 * @describe: 
 */
import 'package:flutter/material.dart';
import 'package:flutter_pc_manager/app/components/button_small_widget.dart';
import 'package:flutter_pc_manager/app/modules/statistics_manager/views/turnover_widget.dart';
import 'package:flutter_pc_manager/app/modules/statistics_manager/views/user_widget.dart';
import 'package:get/get_state_manager/get_state_manager.dart';

import '../controllers/statistics_manager_controller.dart';

class StatisticsManagerView extends StatefulWidget {
  const StatisticsManagerView({super.key});

  @override
  State<StatisticsManagerView> createState() => _StatisticsManagerViewState();
}

class _StatisticsManagerViewState extends State<StatisticsManagerView> {
  final StatisticsManagerController _controller = StatisticsManagerController();

  @override
  void initState() {
    _controller.fetchTurnoverData('2024-10-14', '2024-10-16');
    _controller.fetchUserData('2024-10-14', '2024-10-16');
  }

  @override
  Widget build(BuildContext context) {
    return Obx(
      () => GridView.count(
        crossAxisCount: 2,
        children: [
          TurnoverWidget(
              dataX: _controller.turnoverX.value,
              dataY: _controller.turnoverY.value),
          UserWidget(
              dataX: _controller.userX.value,
              dataY: _controller.totalUserY.value,
              data2Y: _controller.newUserY.value)
        ],
      ),
    );
  }
}
